Skip to content

Conversation

AkihiroSuda
Copy link
Member

No description provided.

@AkihiroSuda

This comment was marked as resolved.

@AkihiroSuda

This comment was marked as resolved.

@afbjorklund
Copy link
Member

afbjorklund commented Oct 15, 2025

[ERROR NumCPU]: the number of available CPUs 1 is less than the required 2
[ERROR Mem]: the system RAM (955 MB) is less than the minimum 1700 MB

I actually hadn't looked at this before, but I know that kind is hacking the preflight.

--skip-phases=preflight

Apparently always having 2 vCPU and 2 GiB total RAM is not so important, after all...

But better to do a more selective ignore.

@AkihiroSuda
Copy link
Member Author

The default CPU and memory seems enough to pass the CI

Comment on lines +378 to +384
# Wish we could use BATS_TEST_RETRIES=3 as an environment variable here,
# but bats does not seem to support it.
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 30
retry_on: error
max_attempts: 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to set the variable inside the test that is flaky; the harness sets it to 0, so you can't set it from the outside:

cat random.bats
@test "flaky test that fails 70% of the time" {
    BATS_TEST_RETRIES=10
    echo "Attempt $BATS_TEST_TRY_NUMBER/$BATS_TEST_RETRIES" >&3
    (( RANDOM % 10 < 3))
}./hack/bats/lib/bats-core/bin/bats random.bats
random.bats
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 1/10
 ✓ flaky test that fails 70% of the time
Attempt 2/10

1 test, 0 failures./hack/bats/lib/bats-core/bin/bats random.bats
random.bats
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 1/10
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 2/10
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 3/10
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 4/10
   flaky test that fails 70% of the time                                                                                                                             1/1
Attempt 5/10
 ✓ flaky test that fails 70% of the time
Attempt 6/10

1 test, 0 failures

Without the logging you cannot tell if the test needed retries to pass (and BATS_TEST_RETRY_NUMBER is not defined in setup or teardown).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set it at the file level, so it applies to every test in the same file:

BATS_TEST_RETRIES=10

@test "flaky test that fails 70% of the time" {
    echo "Attempt $BATS_TEST_TRY_NUMBER/$BATS_TEST_RETRIES" >&3
    (( RANDOM % 10 < 3))
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel GHA YAML is the right place to set BATS_TEST_RETRIES. Maybe we should submit a proposal to the upstream.

Can we just merge this PR?

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

Improvements can be made in later iterations.

Comment on lines +15 to +19
for tag in "${BATS_TEST_TAGS[@]}"; do
if [[ $tag =~ ^nodes:([0-9]+)$ ]]; then
nodes="${BASH_REMATCH[1]}"
fi
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that this is a good way to control setup for individual tests.

I think it would be clearer not to rely on local_setup, but to have each test call a setup function with an argument, like

@test 'Single-node configuration' {
   setup_nodes 1
   # ...
}
@test 'Multi-node configuration' {
   setup_nodes "${LIMA_BATS_K8S_NODES:-3}"
   # ...
}

And local_teardown could use limactl ls --quiet | grep "^${NAME}-" to get the list of instances to delete.

This also allows you to control the number of nodes from the outside without modifying the test source code to adjust the tag.

(Ab)using the tags to pass arguments to the setup/teardown functions is a bit confusing, and should be simpler. But we can always change this later, e.g. when there actually is a multi-node test.

done
}

k() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call it kubectl for readability. Local functions always take precedence over running external programs.

@jandubois jandubois merged commit f9ab640 into lima-vm:master Oct 18, 2025
63 of 65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants